package com.panda.controller.auth;

import com.panda.entity.vo.UserVo;
import com.panda.service.LoginService;
import com.panda.utils.RespondResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin")
// 排除要跳转的页面
public class LoginController {

    private final LoginService loginService;

    @Autowired
    public LoginController(LoginService loginService) {
        this.loginService = loginService;
    }

    @RequestMapping("login")
    public RespondResult login(@Validated  @RequestBody UserVo user){
        System.out.println(user);
        return loginService.login(user);
    }

    @RequestMapping(value = "logout",method = RequestMethod.DELETE)
    public RespondResult logout(){
        return loginService.logout();
    }
}
